package com.sz.youban.dt.service.terminal;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.sz.youban.dt.entity.terminal.DtCallRecords;
import com.sz.youban.dt.interfs.terminal.IDtCallRecordsService;
import com.sz.youban.dt.service.terminal.mapper.DtCallRecordsMapper;

/**
 * <p>
 * 通话记录信息 服务实现类
 * </p>
 *
 * @author liyang
 * @since 2017-06-05
 */
@Service
public class DtCallRecordsServiceImpl extends ServiceImpl<DtCallRecordsMapper, DtCallRecords> implements IDtCallRecordsService {

	private final Logger log = LoggerFactory.getLogger(this.getClass());

	@Autowired 
	private DtCallRecordsMapper callRecordsMapper;
	
	@Override
	public int saveCallRecords(DtCallRecords callRecords) {
		
		int result = callRecordsMapper.insert(callRecords);
		
		return result;
		
	}

	@Override
	public Map<String, String> selectRecordTime(String appPhone) {
		DtCallRecords callRecords = callRecordsMapper.selectByAppPhone(appPhone);

		Map<String,String> map = new HashMap<String,String>();
		if (callRecords != null){
			Date lastTime = callRecords.getStartTime();
			log.info("-----lastTime : {}",lastTime);
			map.put("exist","1");
			map.put("lastTime",lastTime.getTime()+"");
		}else{
			map.put("exist","0");
			map.put("lastTime","");
		}
		return map;
	}


}
